package br.com.rglariguet.pioneer.dao;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import br.com.rglariguet.pioneer.modelos.Manual;

@Repository
@Transactional
public class ManualDAO extends DaoGenerico<Manual> {
	public List<Manual> listarTodos() {
		return (List<Manual>)getSession().createQuery("from Manual as manual").list();
	}
	
	
	public Manual buscaPorCodigo(long codigo) {
		return (Manual) getSession()
				.createQuery(
						"from Manual as manual where manual.codigo = :codigo")
				.setParameter("codigo", codigo).uniqueResult();
		
	}
	
	public List<Manual> buscaPorNome(String nome) {
		return (List<Manual>) getSession()
				.createQuery(
						"from Manual as manual where manual.nome like :nome")
				.setParameter("nome", "%"+nome+"%").list();
		
	}

}
